﻿using LCL.LData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LCL.Config
{
    /// <summary>
    /// DbConfig配置信息类
    /// </summary>
    [Serializable]
    public partial class DbConfigInfo : IConfigInfo
    {
        public LDbType DbType { get; set; }
        public string DbHost { get; set; }
        public string DbUser { get; set; }
        public string DbPwd { get; set; }
        public string DbName { get; set; }
        public string DbTableName { get; set; }
        /// <summary>
        /// 连接字符串
        /// </summary>
        public string ConnectionString
        {
            get
            {
                string temp = "user id=" + DbUser + ";password=" + DbPwd + ";initial catalog=" + DbName + ";Data Source=" + DbHost;
                switch (DbType)
                {
                    case LDbType.SQLServer:
                        temp = "User ID=" + DbUser + ";Password=" + DbPwd + ";initial catalog=" + DbName + ";Data Source=" + DbHost;
                        break;
                    case LDbType.Oracle:
                        temp = "Data Source=" + DbHost + ";User ID=" + DbUser + ";Password=" + DbPwd;
                        break;
                    case LDbType.MySQL:
                        temp = @"server=" + DbHost + ";uid=" + DbUser + ";password=" + DbPwd + ";database=" + DbName + ";pooling=false";
                        break;
                    case LDbType.SQLite:
                        temp = "Data Source=" + DbHost + ";Password=" + DbPwd;
                        break;
                }
                return temp;
            }
        }
    }
}
